package com.wt.comtroller;

import com.wt.pojo.User;
import com.wt.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping
@RestController
public class ConsummerController {

    @Resource
    private UserService userService;

    @PostMapping
    public String add(User u) {
        System.out.println("----------消费者添加--------------user="+u);
        return  userService.add(u);
    }

    @DeleteMapping("/{id}")
    public String delete(@PathVariable("id") Integer uid) {
        System.out.println("---------消费者删除--------------uid="+uid);
        return userService.delete(uid);
    }

    @PutMapping
    public String update(User u) {
        System.out.println("----------消费者修改--------------user="+u);
        return userService.update(u);
    }

    @GetMapping
    public List<User> list(@RequestParam("name") String name, @RequestParam("age")  Integer age) {
        System.out.println("----------查询--------------");
        System.out.println("消费者==name"+name+"  age="+age);
        return userService.list(name,age);
    }

}
